/*    file: TimestampChecker.h
 *    desc:
 *   
 * created: 2016-06-30
 *  author: chuanjiang.zh@qq.com
 * company: 
 */ 


#if !defined TIMESTAMPCHECKER_H_
#define TIMESTAMPCHECKER_H_

#include "TimePoint.h"
#include "TimeHelper.h"


namespace util
{

class DLLEXPORT TimestampChecker
{
public:
	struct Result
	{
		int64_t clockDiff;
		int64_t tsDiff;
		int64_t offset;
	};
public:
    
    TimestampChecker();

    void reset();
    
    int64_t input(int64_t clk, int64_t pts, Result* lastResult, Result* startResult);

    int64_t getCount() const;

    const av::TimePoint& getStartPoint() const
    {
    	return m_start;
    }

    const av::TimePoint& getLastPoint()
    {
    	return m_last;
    }

protected:
    int64_t compute(const av::TimePoint& curPoint, const av::TimePoint& refPoint, Result& result);

protected:
    av::TimePoint m_start;
    av::TimePoint m_last;
    int64_t   m_count;

};


}



#endif //TIMESTAMPCHECKER_H_

